package com.ky.my.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ky.my.entity.Question;
import com.ky.my.mapper.QuestionMapper;
import com.ky.my.service.QuestionService;

import com.ky.common.vo.R;
import com.ky.my.entity.Question;
import com.ky.my.mapper.QuestionMapper;
import com.ky.my.service.QuestionService;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hmt
 * @since 2024-06-19
 */
@Service
public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> implements QuestionService {
    @Autowired
    private QuestionMapper questionMapper;
    @Override
    public R findAll() {
        List<Question> questions = questionMapper.selectList(null);
        return R.ok(questions);
    }

    @Override
    public R findAllQuestionByType(Integer type) {
        if (type == 0){
            List<Question> questions = questionMapper.selectList(null);
            return R.ok(questions);
        }else {
            QueryWrapper<Question> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("type",type);
            List<Question> questions = questionMapper.selectList(queryWrapper);
            return R.ok(questions);
        }

    }
}
